Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

187
Visualizações
using free national API to get data, "blocked by CORS policy" but works with postman/regular url

I am trying to get books list from National Library API (free for public use). It gives back JSON when visiting the URL in Chrome or hitting the endpoint with Postman. However, I can't get rid of the error when trying to make it through localhost, while developing. when I add: { mode: "no-cors"} to the fetch options, I get a response back, but opaque type, so I can't read the data.

fetch(
  `https://api.nli.org.il/openlibrary/search?api_key=uoX9ZMiaRMIBUF4pX0SEuGXMRpUqQIHrw5XuQKcE&query=title,exact,,AND;language,exact,heb&output_format=json&material_type=books`,
  {
    method: "GET",
    headers: {
      "Access-Control-Allow-Origin": "*",
    },
  }
).then((response) => console.log(response));

Error in console:

Access to fetch at 'https://api.nli.org.il/openlibrary/search?api_key=uoX9ZMiaRMIBUF4pX0SEuGXMRpUqQIHrw5XuQKcE&query=title,exact,%D7%97%D7%A0%D7%95%D7%9A,AND;language,exact,heb&output_format=json&material_type=books' from origin 'http://127.0.0.1:5500' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda